<?php
/*
 * @Author: your name
 * @Date: 2021-02-22 15:55:29
 * @LastEditTime: 2021-02-23 20:36:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \lh_vue\awesomepos\php\cate_goods.php
 */
//  指定允许其他域名访问
header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:GET, POST, OPTIONS');
// 响应头设置
header('Access-Control-Allow-Credentials:false');

header("Access-Control-Allow-Headers:Content-Type,XFILENAME,XFILECATEGORY,XFILESIZE");

require_once 'Db.php';

$cate_id = $_GET['cate_id'];

//根据分类获取产品信息

function getCateGoods($cate_id){
    $db = new Db();
    $my_db = $db->getDB();
    $_sql = "SELECT id,trade_name,true_price,cover,one_class FROM bd_goods WHERE supplier_id = 67 AND one_class = $cate_id ORDER BY id DESC  LIMIT 20";
    $_result = $my_db->query($_sql);
    $_html = [];
    while(!!$objects = $_result->fetch_object()){
        $_html[] = $objects;
    }
    $db->unDB($_result,$my_db);
    return $_html;
}
$cate_goods = getCateGoods($cate_id);
$data['cate_goods'] = $cate_goods;
echo json_encode($data);